<html>
<head><meta charset="utf-8"><title>skip doctests attribute? · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html">skip doctests attribute?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218762569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218762569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218762569">(Dec 03 2020 at 22:16)</a>:</h4>
<p>I didn't see mention of this in the docs, so perhaps someone here knows if it's possible to mark all doc tests as <code> ```ignore</code> in a scope using attributes. I'm currently using some macro magic to duplicate the doc comment in another venue that can read markdown, and the code snippets are not actually rust code.</p>



<a name="218762673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218762673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218762673">(Dec 03 2020 at 22:17)</a>:</h4>
<p>Btw, if it's not Rust and you don't want Rust syntax highlighting, you can use the <code>text</code> language (<code> ```text</code>).</p>



<a name="218762782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218762782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218762782">(Dec 03 2020 at 22:18)</a>:</h4>
<p>I can't do that because they aren't text either, and the other doc tool that is reading it has a different default language</p>



<a name="218762883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218762883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218762883">(Dec 03 2020 at 22:19)</a>:</h4>
<p>I don't think there's a way to do this.</p>



<a name="218762916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218762916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218762916">(Dec 03 2020 at 22:19)</a>:</h4>
<p>dang</p>



<a name="218762936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218762936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218762936">(Dec 03 2020 at 22:19)</a>:</h4>
<p>what does rustdoc do with unrecognized languages?</p>



<a name="218763054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763054">(Dec 03 2020 at 22:20)</a>:</h4>
<p>Doesn't highlight them nor run tests</p>



<a name="218763081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763081">(Dec 03 2020 at 22:21)</a>:</h4>
<p>I guess that should be alright</p>



<a name="218763192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763192">(Dec 03 2020 at 22:22)</a>:</h4>
<p>I'm not exactly sure but I believe it just inject the raw source (barring <code># code</code> lines)</p>



<a name="218763223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763223">(Dec 03 2020 at 22:22)</a>:</h4>
<p>...but it's markdown?</p>



<a name="218763245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763245">(Dec 03 2020 at 22:22)</a>:</h4>
<p><em>something</em> has to render it</p>



<a name="218763360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763360">(Dec 03 2020 at 22:23)</a>:</h4>
<p>well yes, but it doesn't add blocks inside the <code>&lt;pre&gt;</code> code block (when outputting html)</p>



<a name="218763399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763399">(Dec 03 2020 at 22:24)</a>:</h4>
<p>ah gotcha</p>



<a name="218763473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763473">(Dec 03 2020 at 22:24)</a>:</h4>
<p>It still does <code>#</code> stripping even on unrecognized languages?</p>



<a name="218763486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763486">(Dec 03 2020 at 22:24)</a>:</h4>
<p>I'm currently editing the file for highlighting, it only handles rust, the rest is just pasted betwen <code>&lt;pre&gt;</code></p>



<a name="218763497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763497">(Dec 03 2020 at 22:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F/near/218763473">said</a>:</p>
<blockquote>
<p>It still does <code>#</code> stripping even on unrecognized languages?</p>
</blockquote>
<p>Not sure</p>



<a name="218763586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763586">(Dec 03 2020 at 22:25)</a>:</h4>
<p>well there's escaping so I guess the fallout from that isn't too bad</p>



<a name="218763841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763841">(Dec 03 2020 at 22:27)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="sd">/// ```c</span>
<span class="sd">/// # static int a = 0;</span>
<span class="sd">/// int main(void) {</span>
<span class="sd">///     return 0;</span>
<span class="sd">/// }</span>
<span class="sd">/// ```</span>
<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p><code>touch src/main.rs; cg doc --no-deps; cat target/doc/playground/fn.main.html </code></p>
<p>Output:</p>
<div class="codehilite" data-code-language="HTML"><pre><span></span><code><span class="p">&lt;</span><span class="nt">code</span> <span class="na">class</span><span class="o">=</span><span class="s">"language-c"</span><span class="p">&gt;</span># static int a = 0;
int main(void) {
    return 0;
}
<span class="p">&lt;/</span><span class="nt">code</span><span class="p">&gt;</span>
</code></pre></div>



<a name="218763897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763897">(Dec 03 2020 at 22:28)</a>:</h4>
<p>so <code># lines</code> are not ignored</p>



<a name="218763939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218763939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218763939">(Dec 03 2020 at 22:28)</a>:</h4>
<p>(<code>cg</code> is my local alias for <code>cargo</code>)</p>



<a name="218768036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218768036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218768036">(Dec 03 2020 at 23:11)</a>:</h4>
<p>Related to <code>cg</code>: I also recently learned that you can do <code>cargo r</code>, <code>cargo b</code>, <code>cargo c</code>, and <code>cargo t</code> for run, build, check, and test. So you could do <code>cg r</code> with your setup! (Though <code>cargo d</code> doesn't do <code>cargo doc</code>)</p>



<a name="218768138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218768138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218768138">(Dec 03 2020 at 23:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="307537">Camelid</span> <a href="#narrow/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F/near/218768036">said</a>:</p>
<blockquote>
<p>Related to <code>cg</code>: I also recently learned that you can do <code>cargo r</code>, <code>cargo b</code>, <code>cargo c</code>, and <code>cargo t</code> for run, build, check, and test. So you could do <code>cg r</code> with your setup! (Though <code>cargo d</code> doesn't do <code>cargo doc</code>)</p>
</blockquote>
<p>Well I do <code>cgr</code> (no space) because I have tons of aliases</p>



<a name="218768148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218768148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218768148">(Dec 03 2020 at 23:13)</a>:</h4>
<p><code>git</code> is <code>g</code></p>



<a name="218768271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218768271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218768271">(Dec 03 2020 at 23:14)</a>:</h4>
<p>Aliases are life, I type <code>cg</code> so much</p>



<a name="218768674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/skip%20doctests%20attribute%3F/near/218768674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/skip.20doctests.20attribute.3F.html#218768674">(Dec 03 2020 at 23:19)</a>:</h4>
<p>I have <code>gst</code> for <code>git status</code> -- <code>g=git</code> is a good idea :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>